package com.bite.product.controller;


import com.bite.product.api.ProductApi;
import com.bite.product.model.ProductInfo;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/feign")
public class FeignController {

    @Autowired
    private ProductApi productApi;

    @GetMapping("/o1")
    public String o1(Integer id, String userName, HttpServletResponse response){
        log.info("接收xxxxx:{}",userName);
        response.setStatus(502);
        return productApi.p1(id);
    }

    @GetMapping("/o2")
    public String o2(String name,Integer id){
        return productApi.p2(name,id);
    }

    @GetMapping("/o3")
    public String o3(){
        ProductInfo productInfo = new ProductInfo();
        productInfo.setId(123);
        productInfo.setProductName("鞋子");
        return productApi.p3(productInfo);
    }

    @RequestMapping("/o4")
    public ProductInfo o4(){
        ProductInfo productInfo = new ProductInfo();
        productInfo.setId(1234);
        productInfo.setProductName("鞋子4");
        return productApi.p4(productInfo);
    }

}
